﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace BF
{
    public class FileIO
    {
        #region Private Variables

        #endregion

        #region Public Variables

        #endregion

        #region Void Methods
        public void CreateNewFile(String Path,Boolean Override,Boolean Empty = true,String Text="")
        {
            if ((!File.Exists(Path))) //Checking if file exists or not
            {
                //create new file
                FileStream fs = File.Create(Path); //Creates file
                StreamWriter sw = new StreamWriter(fs);
                if (!Empty)
                {
                    sw.Write(Text);
                }
                sw.Close();
                fs.Close(); //Closes file stream
            }
            else
            {
                //file exists 
                if (Override)
                {
                    FileStream fs = File.Create(Path); //Creates file
                    StreamWriter sw = new StreamWriter(fs);
                    if (!Empty)
                    {
                        sw.Write(Text);
                    }
                    sw.Close();
                    fs.Close(); //Closes file stream
                }
            }
            
        }
        
        #endregion
        public FileIO()
        {
            
        }
    }
}
